package io.kiki.sba.registry.server.metadata.remoting.session;

import io.kiki.sba.registry.api.exchange.NodeExchanger;
import io.kiki.sba.registry.common.model.metaserver.nodes.ClientInterfaceNode;
import io.kiki.sba.registry.server.metadata.lease.session.ClientInterfaceNodeManager;
import io.kiki.sba.registry.server.metadata.remoting.SessionNodeExchanger;
import io.kiki.sba.registry.server.metadata.remoting.connection.ClientInterfaceConnectionManager;
import io.kiki.sba.registry.server.metadata.remoting.connection.NodeConnectManager;
import io.kiki.sba.registry.server.metadata.remoting.notifier.AbstractNotifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class DefaultSessionServerService extends AbstractNotifier<ClientInterfaceNode> implements SessionServerService {

    @Autowired
    private SessionNodeExchanger sessionNodeExchanger;

    @Autowired
    private ClientInterfaceConnectionManager clientInterfaceConnectionManager;

    @Autowired
    private ClientInterfaceNodeManager clientInterfaceNodeManager;

    @Override
    protected NodeExchanger getNodeExchanger() {
        return sessionNodeExchanger;
    }

    @Override
    protected List<ClientInterfaceNode> getDataStoreNodeList() {
        return clientInterfaceNodeManager.getSessionServerMetaInfo().getList();
    }

    @Override
    protected NodeConnectManager getNodeConnectManager() {
        return clientInterfaceConnectionManager;
    }


    DefaultSessionServerService setSessionNodeExchanger(SessionNodeExchanger sessionNodeExchanger) {
        this.sessionNodeExchanger = sessionNodeExchanger;
        return this;
    }


    DefaultSessionServerService setSessionConnectionHandler(ClientInterfaceConnectionManager clientInterfaceConnectionManager) {
        this.clientInterfaceConnectionManager = clientInterfaceConnectionManager;
        return this;
    }


    DefaultSessionServerService setSessionServerManager(ClientInterfaceNodeManager clientInterfaceNodeManager) {
        this.clientInterfaceNodeManager = clientInterfaceNodeManager;
        return this;
    }
}
